var userError = document.getElementById("userError");
var pwdError = document.getElementById("pwdError");
var canSubmitByRightUser = false;
var canSubmitByRightPwd = false;
function usermouseout(e){
    var rightP = /^[a-zA-Z][A-Za-z0-9]{2,19}$/
    var startErrorP = /^[0-9]/
    if(rightP.test(e.value)){
        userError.innerHTML="✔用户名格式正确";
        userError.style.color="green";
        canSubmitByRightUser = true
    } else {
        userError.style.color="red";
        var inputvalue = e.value+"";
        if(inputvalue.length<=3){
            userError.innerHTML="*用户名长度最少为3位！"
        }
        if(inputvalue.length>3){
            userError.innerHTML="*用户名长度至多为20位！"
        }
        if(startErrorP.test(e.value)){
            userError.innerHTML="*用户名不能以数字开头！！"
        }
        canSubmitByRightUser = false
    }
}
function pswmouseout(e){
    var rightP = /^[\w]{6,12}$/
    if(rightP.test(e.value)){
        pwdError.innerHTML="✔密码可用";
        pwdError.style.color="green";
        canSubmitByRightPwd = true;
    } else {
        pwdError.style.color="red";
        pwdError.innerHTML="*密码长度为6-12位!只能是字母数字和下划线"
        canSubmitByRightPwd = false
    }
}
function canSubmit(){
    if(canSubmitByRightUser&&canSubmitByRightPwd)
        return true;
    return false;
}